<?php
// error_reporting(E_ALL);
// ini_set("display_errors","On");

//就近 www.jiujin.me
if (!defined('IN_IA')) {
	die('Access Denied');
}
global $_W, $_GPC;
$id = $_GPC['id'];
$qid = !empty($_GPC['qid']) ? $_GPC['qid'] : '1';
$openid = m('user')->getOpenid();
$member = m('member')->getInfo($openid);
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if($operation == 'display'){
       if(empty($_GPC['company']) && empty($_GPC['id']) && empty($_GPC['qid']) && empty($_GPC['brandname']) && empty($_GPC['goodsname']) && empty($_GPC['production_time'])){
          exit;
       }
       $info=pdo_fetch('select * from '.tablename('authenticity_information').'where  uniacid=:uniacid and qid=:qid',array(':uniacid'=>$_W['uniacid'],':qid'=>$_GPC['qid']));
       if(!empty($info)){
         $lot=pdo_fetch('select * from '.tablename('authenticity_lottery').'where  uniacid=:uniacid and id=:id',array(':uniacid'=>$_W['uniacid'],':id'=>$info['auth_id']));
         $url="http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=detail&m=hx_lottery&id=".$lot['lottery_id']."&qid=".$_GPC['qid'];
         header("Location: $url");
       }
}
if($operation == 'post'){
   if(!empty($_GPC['data'])){
       $data=$_GPC['data'];
       $data['openid']=$openid;
       $data['uniacid']=$_W['uniacid'];
       $data['createtime']=time();
       pdo_insert('authenticity_information',$data);
       $info=pdo_fetch('select * from '.tablename('authenticity_lottery').'where  uniacid=:uniacid and id=:id',array(':uniacid'=>$_W['uniacid'],':id'=>$data['auth_id']));
       show_json(1,array('lottery_id'=>$info['lottery_id'],'qid'=>$data['qid'])); 
   }else{
       show_json(0);  
   }
}
include $this->template('authenticity/list');

